package com.ellwood.copyright;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
import java.net.InetAddress;

/**
 * @ProjectName: ell-copyright-pro
 * @PackageName: com.ellwood.copyright
 * @ClassName: EllwoodApplication
 * @Description: // 启动
 * @Author: Ellwood
 * @CreateDate: 2024/11/8 - 21:43
 * @Version: V1.0.0
 */
@Slf4j
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
public class EllwoodApplication extends SpringBootServletInitializer {

    @SneakyThrows
    public static void main(String[] args) {
        SpringApplication sa=new SpringApplication(EllwoodApplication.class);
        ConfigurableApplicationContext context = sa.run(args);
        ConfigurableEnvironment env = context.getEnvironment();
        log.info(
                "\n Ellwood-IPGuard-boot管理系统启动成功！！\n" +
                        "----------------------------------------------------------\\n\\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \thttp://{}:{}\n\t" +
                        "Doc: \thttp://{}:{}/doc.html\n" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port")
        );
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(EllwoodApplication.class);
    }
}
